Kanzi 4.0.0-beta2
kanzi::Mesh::MorphData Struct Reference

Morph data associated with deforming this mesh. More...

#include <kanzi/core.ui/graphics3d/mesh.hpp>

Classes

class  MorphShape
 Morph shape. More...
 

Public Member Functions

void addShape (string_view name, float weight)
 Adds a morph shape.
 
void allocateShapes (size_t shapeCount)
 Allocates the shape array.
 
void createBuffer (Renderer &renderer, string_view name, gfx::BufferHandleGuard bufferHandle, size_t dataSize)
 Create the internal vertex buffer using an external buffer handle, but do not deploy data.
 
void createBuffer (Renderer &renderer, string_view name, size_t dataSize)
 Create the internal vertex buffer, but do not deploy data.
 
void deploy (Renderer &renderer, string_view name, const vector< byte > &data)
 Deploy the morph data to the GPU.
 
void destroyBuffer ()
 Destroy the GPU-side data.
 
size_t getBufferDataSize () const
 Gets the data size to use for buffers.
 
size_t getCPUMemoryUsage () const
 Gets the GPU memory usage of the morph data.
 
size_t getDataTextureNormalOffset () const
 Gets the data texture normal offset.
 
size_t getDataTexturePositionOffset () const
 Gets the data texture position offset.
 
size_t getDataTextureTangentOffset () const
 Gets the data texture tangent offset.
 
size_t getDataTextureTargetSize () const
 Gets the data texture target size.
 
size_t getGPUMemoryUsage () const
 Gets the GPU memory usage of the morph data.
 
gfx::BufferHandleGuard getHandle () const
 Gets the handle of the morph buffer.
 
const MorphShapegetShape (size_t idx) const
 Gets a shape by index.
 
size_t getShapeCount () const
 Gets the number of shapes.
 
const vector< MorphShape > & getShapes () const
 Gets the shape array.
 
size_t getTargetCount () const
 Gets the morph target count.
 
size_t getTargetSize () const
 Gets the target size.
 
size_t getVertexCount () const
 Gets the vertex count.
 
const MeshVertexFormatgetVertexFormat () const
 Gets the vertex format.
 
bool hasVertexBuffer () const
 Indicates whether or not the morph data has a vertex buffer.
 
bool isDeployed () const
 Indicates whether or not the morph data is deployed to the GPU.
 
void setDataTextureSettings (size_t positionOffset, size_t normalOffset, size_t tangentOffset, size_t targetSize)
 Sets the data texture settings.
 
void setShape (size_t idx, string_view name, float weight)
 Sets given shape by index.
 
void setVertexCount (size_t vertexCount)
 Sets the vertex count.
 
void setVertexData (vector< byte > vertexData)
 Sets the vertex data.
 
void setVertexFormat (const MeshVertexFormat &vertexFormat)
 Sets the vertex format.
 
void updateTargetSize ()
 Updates the target size based on vertex format and vertex count.
 

Protected Attributes

size_t m_dataTextureNormalOffset
 Data texture normal offset.
 
size_t m_dataTexturePositionOffset
 Data texture position offset.
 
size_t m_dataTextureTangentOffset
 Data texture tangent offset.
 
size_t m_dataTextureTargetSize
 Data texture target size.
 
vector< MorphShapem_shapes
 Morph shapes.
 
size_t m_targetSize
 Size of one full morph target in bytes.
 
GPUBufferUniquePtr m_vertexBuffer
 Buffer for GPU-side vertex data.
 
size_t m_vertexCount
 Number of vertices per morph target.
 
vector< byte > m_vertexData
 Raw vertex data.
 
MeshVertexFormat m_vertexFormat
 Morph-specific vertex format.
 

Detailed Description

Morph data associated with deforming this mesh.

To animate morph weights, animate the Model3D::Morphing property in a Model3D that has a Mesh containing Mesh::MorphData:

// Create float animation and add two keyframes.
FloatKeyframeAnimation::create(domain);
morphAnimation->addLinearKeyframe(chrono::milliseconds(0), 0.0f);
morphAnimation->addLinearKeyframe(chrono::milliseconds(100), 1.0f);
// Create a range index animation timeline and apply it to the Morphing property of the current node.
RangeIndexAnimationTimeline::create(domain, ".", Model3D::MorphingProperty);
// Animate the first morph target using the keyframe animation (this animation goes from weight zero to one).
rangeIndexTimeline->addEntry(0, PropertyFieldWhole, morphAnimation);
// Create range index animation timeline playback.
RangeIndexAnimationTimelinePlayback::create(rangeIndexTimeline, context);
Since
Kanzi 4.0.0

Member Function Documentation

◆ createBuffer() [1/2]

void kanzi::Mesh::MorphData::createBuffer ( Renderer & renderer,
string_view name,
gfx::BufferHandleGuard bufferHandle,
size_t dataSize )

Create the internal vertex buffer using an external buffer handle, but do not deploy data.

Parameters
rendererRenderer to use.
nameMesh name.
bufferHandleExternal buffer handle
dataSizevertex data size.

◆ createBuffer() [2/2]

void kanzi::Mesh::MorphData::createBuffer ( Renderer & renderer,
string_view name,
size_t dataSize )

Create the internal vertex buffer, but do not deploy data.

Parameters
rendererRenderer to use.
nameMesh name.
dataSizevertex data size.

◆ deploy()

void kanzi::Mesh::MorphData::deploy ( Renderer & renderer,
string_view name,
const vector< byte > & data )

Deploy the morph data to the GPU.

Calling this function releases the CPU-side morph data.

Parameters
rendererRenderer to use.
nameMesh name.
dataVertex data to upload.

◆ destroyBuffer()

void kanzi::Mesh::MorphData::destroyBuffer ( )

Destroy the GPU-side data.

◆ isDeployed()

bool kanzi::Mesh::MorphData::isDeployed ( ) const
inline

Indicates whether or not the morph data is deployed to the GPU.

Returns
If the morph data is deployed true, false otherwise.

◆ getShape()

const MorphShape & kanzi::Mesh::MorphData::getShape ( size_t idx) const
inline

Gets a shape by index.

Parameters
idxIndex of a shape.
Returns
Reference to a shape by index.

◆ getShapeCount()

size_t kanzi::Mesh::MorphData::getShapeCount ( ) const
inline

Gets the number of shapes.

Returns
Number of shapes.

◆ getShapes()

const vector< MorphShape > & kanzi::Mesh::MorphData::getShapes ( ) const
inline

Gets the shape array.

Returns
Reference to a vector of shapes.

◆ getTargetCount()

size_t kanzi::Mesh::MorphData::getTargetCount ( ) const
inline

Gets the morph target count.

Returns
Number of morph targets.

◆ addShape()

void kanzi::Mesh::MorphData::addShape ( string_view name,
float weight )
inline

Adds a morph shape.

Parameters
nameShape name.
weightShape weight.

◆ allocateShapes()

void kanzi::Mesh::MorphData::allocateShapes ( size_t shapeCount)
inline

Allocates the shape array.

Parameters
shapeCountNumber of shapes.

◆ setShape()

void kanzi::Mesh::MorphData::setShape ( size_t idx,
string_view name,
float weight )
inline

Sets given shape by index.

Parameters
idxIndex.
nameShape name.
weightShape weight.

◆ getVertexCount()

size_t kanzi::Mesh::MorphData::getVertexCount ( ) const
inline

Gets the vertex count.

Returns
Vertex count.

◆ getVertexFormat()

const MeshVertexFormat & kanzi::Mesh::MorphData::getVertexFormat ( ) const
inline

Gets the vertex format.

Returns
Reference to the vertex format.

◆ getTargetSize()

size_t kanzi::Mesh::MorphData::getTargetSize ( ) const
inline

Gets the target size.

Returns
Size of one morph target in bytes.

◆ setVertexCount()

void kanzi::Mesh::MorphData::setVertexCount ( size_t vertexCount)
inline

Sets the vertex count.

Parameters
vertexCountVertex count.

◆ setVertexFormat()

void kanzi::Mesh::MorphData::setVertexFormat ( const MeshVertexFormat & vertexFormat)
inline

Sets the vertex format.

Parameters
vertexFormatVertex format.

◆ updateTargetSize()

void kanzi::Mesh::MorphData::updateTargetSize ( )
inline

Updates the target size based on vertex format and vertex count.

◆ getBufferDataSize()

size_t kanzi::Mesh::MorphData::getBufferDataSize ( ) const
inline

Gets the data size to use for buffers.

The data size is aligned to 4 bytes.

◆ setVertexData()

void kanzi::Mesh::MorphData::setVertexData ( vector< byte > vertexData)
inline

Sets the vertex data.

Target size and target count must be set prior to assigning the data. The input data is extended to buffer data size if necessary.

Parameters
vertexDataVertex data blob to set.

◆ getDataTexturePositionOffset()

size_t kanzi::Mesh::MorphData::getDataTexturePositionOffset ( ) const
inline

Gets the data texture position offset.

Returns
Data texture position offset in texels.

◆ getDataTextureNormalOffset()

size_t kanzi::Mesh::MorphData::getDataTextureNormalOffset ( ) const
inline

Gets the data texture normal offset.

Returns
Data texture normal offset in texels.

◆ getDataTextureTangentOffset()

size_t kanzi::Mesh::MorphData::getDataTextureTangentOffset ( ) const
inline

Gets the data texture tangent offset.

Returns
Data texture tangent offset in texels.

◆ getDataTextureTargetSize()

size_t kanzi::Mesh::MorphData::getDataTextureTargetSize ( ) const
inline

Gets the data texture target size.

Returns
Data texture target size in texels.

◆ setDataTextureSettings()

void kanzi::Mesh::MorphData::setDataTextureSettings ( size_t positionOffset,
size_t normalOffset,
size_t tangentOffset,
size_t targetSize )
inline

Sets the data texture settings.

Parameters
positionOffsetData texture position offset.
normalOffsetData texture normal offset.
tangentOffsetData texture tangent offset.
targetSizeData texture morph target size.

◆ getGPUMemoryUsage()

size_t kanzi::Mesh::MorphData::getGPUMemoryUsage ( ) const
inline

Gets the GPU memory usage of the morph data.

Returns
Memory usage in bytes.

◆ getCPUMemoryUsage()

size_t kanzi::Mesh::MorphData::getCPUMemoryUsage ( ) const
inline

Gets the GPU memory usage of the morph data.

Returns
Memory usage in bytes.

◆ hasVertexBuffer()

bool kanzi::Mesh::MorphData::hasVertexBuffer ( ) const
inline

Indicates whether or not the morph data has a vertex buffer.

Returns
If the morph data has a vertex buffer true, false otherwise.

◆ getHandle()

gfx::BufferHandleGuard kanzi::Mesh::MorphData::getHandle ( ) const
inline

Gets the handle of the morph buffer.

Returns
Handle of the morph buffer.

Member Data Documentation

◆ m_vertexBuffer

GPUBufferUniquePtr kanzi::Mesh::MorphData::m_vertexBuffer
protected

Buffer for GPU-side vertex data.

◆ m_shapes

vector<MorphShape> kanzi::Mesh::MorphData::m_shapes
protected

Morph shapes.

◆ m_vertexCount

size_t kanzi::Mesh::MorphData::m_vertexCount
protected

Number of vertices per morph target.

◆ m_targetSize

size_t kanzi::Mesh::MorphData::m_targetSize
protected

Size of one full morph target in bytes.

◆ m_vertexFormat

MeshVertexFormat kanzi::Mesh::MorphData::m_vertexFormat
protected

Morph-specific vertex format.

◆ m_vertexData

vector<byte> kanzi::Mesh::MorphData::m_vertexData
protected

Raw vertex data.

◆ m_dataTexturePositionOffset

size_t kanzi::Mesh::MorphData::m_dataTexturePositionOffset
protected

Data texture position offset.

◆ m_dataTextureNormalOffset

size_t kanzi::Mesh::MorphData::m_dataTextureNormalOffset
protected

Data texture normal offset.

◆ m_dataTextureTangentOffset

size_t kanzi::Mesh::MorphData::m_dataTextureTangentOffset
protected

Data texture tangent offset.

◆ m_dataTextureTargetSize

size_t kanzi::Mesh::MorphData::m_dataTextureTargetSize
protected

Data texture target size.


The documentation for this struct was generated from the following file: